<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>pln_inco.Freeling</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            >alan</th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        Package&nbsp;pln_inco ::
        Module&nbsp;Freeling
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="pln_inco.Freeling-pysrc.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="pln_inco.Freeling-module.html">Module pln_inco.Freeling</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-comment"># -*- coding: UTF-8 -*-</tt> </tt>
<a name="L2"></a><tt class="py-lineno">  2</tt>  <tt class="py-line"> </tt>
<a name="L3"></a><tt class="py-lineno">  3</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">os</tt> </tt>
<a name="L4"></a><tt class="py-lineno">  4</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">re</tt> </tt>
<a name="L5"></a><tt class="py-lineno">  5</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">subprocess</tt> <tt class="py-keyword">import</tt> <tt class="py-name">Popen</tt><tt class="py-op">,</tt> <tt class="py-name">PIPE</tt> </tt>
<a name="L6"></a><tt class="py-lineno">  6</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">pln_inco</tt><tt class="py-op">.</tt><tt class="py-name">util</tt><tt class="py-op">.</tt><tt id="link-0" class="py-name" targets="Module pln_inco.util.Tokenizador=pln_inco.util.Tokenizador-module.html"><a title="pln_inco.util.Tokenizador" class="py-name" href="#" onclick="return doclink('link-0', 'Tokenizador', 'link-0');">Tokenizador</a></tt> <tt class="py-keyword">import</tt> <tt class="py-op">*</tt> </tt>
<a name="L7"></a><tt class="py-lineno">  7</tt>  <tt class="py-line"> </tt>
<a name="L8"></a><tt class="py-lineno">  8</tt>  <tt class="py-line"> </tt>
<a name="L9"></a><tt class="py-lineno">  9</tt>  <tt class="py-line"><tt class="py-comment"># Utilizamos el 'analyzer' de FreeLing</tt> </tt>
<a name="L10"></a><tt class="py-lineno"> 10</tt>  <tt class="py-line"><tt class="py-comment"># La variable de entorno $FREELINGSHARE debe estar seteada</tt> </tt>
<a name="L11"></a><tt class="py-lineno"> 11</tt>  <tt class="py-line"><tt id="link-1" class="py-name" targets="Variable pln_inco.Freeling.base_cmd_freeling=pln_inco.Freeling-module.html#base_cmd_freeling"><a title="pln_inco.Freeling.base_cmd_freeling" class="py-name" href="#" onclick="return doclink('link-1', 'base_cmd_freeling', 'link-1');">base_cmd_freeling</a></tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-string">'analyzer'</tt><tt class="py-op">,</tt> <tt class="py-string">'-f'</tt><tt class="py-op">,</tt> <tt class="py-string">'%s/config/es.cfg'</tt> <tt class="py-op">%</tt> <tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">environ</tt><tt class="py-op">[</tt><tt class="py-string">'FREELINGSHARE'</tt><tt class="py-op">]</tt><tt class="py-op">]</tt> </tt>
<a name="L12"></a><tt class="py-lineno"> 12</tt>  <tt class="py-line"> </tt>
<a name="L13"></a><tt class="py-lineno"> 13</tt>  <tt class="py-line"> </tt>
<a name="salidaProceso"></a><div id="salidaProceso-def"><a name="L14"></a><tt class="py-lineno"> 14</tt> <a class="py-toggle" href="#" id="salidaProceso-toggle" onclick="return toggle('salidaProceso');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pln_inco.Freeling-module.html#salidaProceso">salidaProceso</a><tt class="py-op">(</tt><tt class="py-param">cmd</tt><tt class="py-op">,</tt> <tt class="py-param">entrada</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="salidaProceso-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="salidaProceso-expanded"><a name="L15"></a><tt class="py-lineno"> 15</tt>  <tt class="py-line">        <tt class="py-docstring">"""Ejecuta el proceso referido en cmd.</tt> </tt>
<a name="L16"></a><tt class="py-lineno"> 16</tt>  <tt class="py-line"><tt class="py-docstring">        Devuelve una lista con todas las l&#237;neas de la salida."""</tt> </tt>
<a name="L17"></a><tt class="py-lineno"> 17</tt>  <tt class="py-line">        <tt class="py-keyword">print</tt> <tt class="py-name">cmd</tt> </tt>
<a name="L18"></a><tt class="py-lineno"> 18</tt>  <tt class="py-line">        <tt class="py-name">p</tt> <tt class="py-op">=</tt> <tt class="py-name">Popen</tt><tt class="py-op">(</tt><tt class="py-name">cmd</tt><tt class="py-op">,</tt> <tt class="py-name">stdin</tt><tt class="py-op">=</tt><tt class="py-name">PIPE</tt><tt class="py-op">,</tt> <tt class="py-name">stdout</tt><tt class="py-op">=</tt><tt class="py-name">PIPE</tt><tt class="py-op">)</tt> </tt>
<a name="L19"></a><tt class="py-lineno"> 19</tt>  <tt class="py-line">        <tt class="py-comment"># Freeling no soporta UTF-8</tt> </tt>
<a name="L20"></a><tt class="py-lineno"> 20</tt>  <tt class="py-line">        <tt class="py-name">salida_pipe</tt> <tt class="py-op">=</tt> <tt class="py-name">p</tt><tt class="py-op">.</tt><tt class="py-name">communicate</tt><tt class="py-op">(</tt><tt class="py-name">input</tt><tt class="py-op">=</tt><tt class="py-name">entrada</tt><tt class="py-op">.</tt><tt class="py-name">encode</tt><tt class="py-op">(</tt><tt class="py-string">'iso-8859-1'</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt class="py-name">decode</tt><tt class="py-op">(</tt><tt class="py-string">'iso-8859-1'</tt><tt class="py-op">)</tt> </tt>
<a name="L21"></a><tt class="py-lineno"> 21</tt>  <tt class="py-line">        <tt class="py-name">tokens</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-name">linea</tt> <tt class="py-keyword">for</tt> <tt class="py-name">linea</tt> <tt class="py-keyword">in</tt> <tt class="py-name">salida_pipe</tt><tt class="py-op">.</tt><tt class="py-name">split</tt><tt class="py-op">(</tt><tt class="py-string">'\n'</tt><tt class="py-op">)</tt><tt class="py-op">]</tt> </tt>
<a name="L22"></a><tt class="py-lineno"> 22</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">tokens</tt> </tt>
</div><a name="L23"></a><tt class="py-lineno"> 23</tt>  <tt class="py-line"> </tt>
<a name="L24"></a><tt class="py-lineno"> 24</tt>  <tt class="py-line"> </tt>
<a name="obtenerSalidaFreeling"></a><div id="obtenerSalidaFreeling-def"><a name="L25"></a><tt class="py-lineno"> 25</tt> <a class="py-toggle" href="#" id="obtenerSalidaFreeling-toggle" onclick="return toggle('obtenerSalidaFreeling');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pln_inco.Freeling-module.html#obtenerSalidaFreeling">obtenerSalidaFreeling</a><tt class="py-op">(</tt><tt class="py-param">texto</tt><tt class="py-op">,</tt> <tt class="py-param">outf</tt><tt class="py-op">,</tt> <tt class="py-param">parametros</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="obtenerSalidaFreeling-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="obtenerSalidaFreeling-expanded"><a name="L26"></a><tt class="py-lineno"> 26</tt>  <tt class="py-line">        <tt class="py-docstring">"""Devuelve una lista con informaci&#243;n del texto, obtenida con Freeling.</tt> </tt>
<a name="L27"></a><tt class="py-lineno"> 27</tt>  <tt class="py-line"><tt class="py-docstring">        Freeling utilizar&#225; el archivo de configuraci&#243;n por defecto para el idioma espa&#241;ol.</tt> </tt>
<a name="L28"></a><tt class="py-lineno"> 28</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L29"></a><tt class="py-lineno"> 29</tt>  <tt class="py-line"><tt class="py-docstring">        En outf se indica el par&#225;metro que se le pasar&#237;a al analyzer</tt> </tt>
<a name="L30"></a><tt class="py-lineno"> 30</tt>  <tt class="py-line"><tt class="py-docstring">        (plain, token, splitted, morfo, tagged, parsed, dep).</tt> </tt>
<a name="L31"></a><tt class="py-lineno"> 31</tt>  <tt class="py-line"><tt class="py-docstring">        En parametros pueden ir m&#225;s par&#225;metros de configuraci&#243;n de Freeling. Por ejemplo,</tt> </tt>
<a name="L32"></a><tt class="py-lineno"> 32</tt>  <tt class="py-line"><tt class="py-docstring">        parametros podr&#237;a ser ['--ner', 'basic', '--noafx'].</tt> </tt>
<a name="L33"></a><tt class="py-lineno"> 33</tt>  <tt class="py-line"><tt class="py-docstring">        </tt> </tt>
<a name="L34"></a><tt class="py-lineno"> 34</tt>  <tt class="py-line"><tt class="py-docstring">        La salida se devuelve como texto plano."""</tt> </tt>
<a name="L35"></a><tt class="py-lineno"> 35</tt>  <tt class="py-line"> </tt>
<a name="L36"></a><tt class="py-lineno"> 36</tt>  <tt class="py-line">        <tt class="py-name">cmd</tt> <tt class="py-op">=</tt>  <tt id="link-2" class="py-name"><a title="pln_inco.Freeling.base_cmd_freeling" class="py-name" href="#" onclick="return doclink('link-2', 'base_cmd_freeling', 'link-1');">base_cmd_freeling</a></tt> <tt class="py-op">+</tt> <tt class="py-op">[</tt><tt class="py-string">'--outf'</tt><tt class="py-op">,</tt> <tt class="py-name">outf</tt><tt class="py-op">]</tt> <tt class="py-op">+</tt> <tt class="py-name">parametros</tt> </tt>
<a name="L37"></a><tt class="py-lineno"> 37</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-op">[</tt><tt class="py-name">linea</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-keyword">for</tt> <tt class="py-name">linea</tt> <tt class="py-keyword">in</tt> <tt id="link-3" class="py-name" targets="Function pln_inco.Freeling.salidaProceso()=pln_inco.Freeling-module.html#salidaProceso"><a title="pln_inco.Freeling.salidaProceso" class="py-name" href="#" onclick="return doclink('link-3', 'salidaProceso', 'link-3');">salidaProceso</a></tt><tt class="py-op">(</tt><tt class="py-name">cmd</tt><tt class="py-op">,</tt> <tt class="py-name">texto</tt><tt class="py-op">)</tt><tt class="py-op">]</tt> </tt>
</div><a name="L38"></a><tt class="py-lineno"> 38</tt>  <tt class="py-line"> </tt>
<a name="L39"></a><tt class="py-lineno"> 39</tt>  <tt class="py-line"> </tt>
<a name="obtenerInfoEtiquetadoFreeling"></a><div id="obtenerInfoEtiquetadoFreeling-def"><a name="L40"></a><tt class="py-lineno"> 40</tt> <a class="py-toggle" href="#" id="obtenerInfoEtiquetadoFreeling-toggle" onclick="return toggle('obtenerInfoEtiquetadoFreeling');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pln_inco.Freeling-module.html#obtenerInfoEtiquetadoFreeling">obtenerInfoEtiquetadoFreeling</a><tt class="py-op">(</tt><tt class="py-param">texto</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="obtenerInfoEtiquetadoFreeling-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="obtenerInfoEtiquetadoFreeling-expanded"><a name="L41"></a><tt class="py-lineno"> 41</tt>  <tt class="py-line">        <tt class="py-docstring">"""Devuelve una lista de las oraciones identificadas por Freeling.</tt> </tt>
<a name="L42"></a><tt class="py-lineno"> 42</tt>  <tt class="py-line"><tt class="py-docstring">        </tt> </tt>
<a name="L43"></a><tt class="py-lineno"> 43</tt>  <tt class="py-line"><tt class="py-docstring">        Cada oraci&#243;n es una lista de tuplas (token, lema, tag gramatical).</tt> </tt>
<a name="L44"></a><tt class="py-lineno"> 44</tt>  <tt class="py-line"><tt class="py-docstring">        Los tokens son los strings tal cu&#225;l los genera Freeling, sin marcas de d&#243;nde comienzan y</tt> </tt>
<a name="L45"></a><tt class="py-lineno"> 45</tt>  <tt class="py-line"><tt class="py-docstring">        terminan en el texto original."""</tt> </tt>
<a name="L46"></a><tt class="py-lineno"> 46</tt>  <tt class="py-line"> </tt>
<a name="L47"></a><tt class="py-lineno"> 47</tt>  <tt class="py-line">        <tt class="py-comment"># Las opciones '--noafx', '--noloc', '--nonumb', '--nodate', '--noquant' no las utilizamos,</tt> </tt>
<a name="L48"></a><tt class="py-lineno"> 48</tt>  <tt class="py-line">        <tt class="py-comment"># pues la funci&#243;n que determina d&#243;nde comienzan y terminan los tokens de Freeling</tt> </tt>
<a name="L49"></a><tt class="py-lineno"> 49</tt>  <tt class="py-line">        <tt class="py-comment"># (obtenerLemasEtiquetasFreeling) funciona de todas formas.</tt> </tt>
<a name="L50"></a><tt class="py-lineno"> 50</tt>  <tt class="py-line">        <tt class="py-comment">#</tt> </tt>
<a name="L51"></a><tt class="py-lineno"> 51</tt>  <tt class="py-line">        <tt class="py-comment"># Las l&#237;neas de freeling vienen en formato "token lema tag prob".</tt> </tt>
<a name="L52"></a><tt class="py-lineno"> 52</tt>  <tt class="py-line">        <tt class="py-name">salida_Freeling</tt> <tt class="py-op">=</tt> <tt id="link-4" class="py-name" targets="Function pln_inco.Freeling.obtenerSalidaFreeling()=pln_inco.Freeling-module.html#obtenerSalidaFreeling"><a title="pln_inco.Freeling.obtenerSalidaFreeling" class="py-name" href="#" onclick="return doclink('link-4', 'obtenerSalidaFreeling', 'link-4');">obtenerSalidaFreeling</a></tt><tt class="py-op">(</tt><tt class="py-name">texto</tt><tt class="py-op">,</tt> <tt class="py-string">'tagged'</tt><tt class="py-op">,</tt> <tt class="py-op">[</tt><tt class="py-string">'--ner'</tt><tt class="py-op">,</tt> <tt class="py-string">'basic'</tt><tt class="py-op">,</tt> <tt class="py-string">'--flush'</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
<a name="L53"></a><tt class="py-lineno"> 53</tt>  <tt class="py-line">        <tt class="py-name">oraciones</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L54"></a><tt class="py-lineno"> 54</tt>  <tt class="py-line">        <tt class="py-name">oracion</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L55"></a><tt class="py-lineno"> 55</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">linea</tt> <tt class="py-keyword">in</tt> <tt class="py-name">salida_Freeling</tt><tt class="py-op">:</tt> </tt>
<a name="L56"></a><tt class="py-lineno"> 56</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">linea</tt> <tt class="py-op">!=</tt> <tt class="py-string">''</tt><tt class="py-op">:</tt> </tt>
<a name="L57"></a><tt class="py-lineno"> 57</tt>  <tt class="py-line">                        <tt class="py-name">oracion</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-name">tuple</tt><tt class="py-op">(</tt><tt class="py-name">linea</tt><tt class="py-op">.</tt><tt class="py-name">split</tt><tt class="py-op">(</tt><tt class="py-string">" "</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L58"></a><tt class="py-lineno"> 58</tt>  <tt class="py-line">                <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L59"></a><tt class="py-lineno"> 59</tt>  <tt class="py-line">                        <tt class="py-name">oraciones</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-name">oracion</tt><tt class="py-op">)</tt> </tt>
<a name="L60"></a><tt class="py-lineno"> 60</tt>  <tt class="py-line">                        <tt class="py-name">oracion</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L61"></a><tt class="py-lineno"> 61</tt>  <tt class="py-line"> </tt>
<a name="L62"></a><tt class="py-lineno"> 62</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">oraciones</tt> </tt>
</div><a name="L63"></a><tt class="py-lineno"> 63</tt>  <tt class="py-line"> </tt>
<a name="L64"></a><tt class="py-lineno"> 64</tt>  <tt class="py-line"> </tt>
<a name="sacarTildes"></a><div id="sacarTildes-def"><a name="L65"></a><tt class="py-lineno"> 65</tt> <a class="py-toggle" href="#" id="sacarTildes-toggle" onclick="return toggle('sacarTildes');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pln_inco.Freeling-module.html#sacarTildes">sacarTildes</a><tt class="py-op">(</tt><tt class="py-param">texto</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="sacarTildes-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="sacarTildes-expanded"><a name="L66"></a><tt class="py-lineno"> 66</tt>  <tt class="py-line">        <tt class="py-docstring">"""Funci&#243;n auxiliar que reemplaza los tildes por su versi&#243;n no acentuada.</tt> </tt>
<a name="L67"></a><tt class="py-lineno"> 67</tt>  <tt class="py-line"><tt class="py-docstring">        Se utiliza solamente en la funci&#243;n obtenerLemasEtiquetasFreeling() para casos</tt> </tt>
<a name="L68"></a><tt class="py-lineno"> 68</tt>  <tt class="py-line"><tt class="py-docstring">        como "cont&#225;ndoselo" que Freeling convierte en "contando", "se", "lo" (saca el</tt> </tt>
<a name="L69"></a><tt class="py-lineno"> 69</tt>  <tt class="py-line"><tt class="py-docstring">        tilde de la primera parte)."""</tt> </tt>
<a name="L70"></a><tt class="py-lineno"> 70</tt>  <tt class="py-line">         </tt>
<a name="L71"></a><tt class="py-lineno"> 71</tt>  <tt class="py-line">        <tt class="py-name">strs</tt> <tt class="py-op">=</tt> <tt class="py-op">{</tt><tt class="py-string">u'&#225;'</tt><tt class="py-op">:</tt> <tt class="py-string">u'a'</tt><tt class="py-op">,</tt> <tt class="py-string">u'&#233;'</tt><tt class="py-op">:</tt> <tt class="py-string">u'e'</tt><tt class="py-op">,</tt> <tt class="py-string">u'&#237;'</tt><tt class="py-op">:</tt> <tt class="py-string">u'i'</tt><tt class="py-op">,</tt> <tt class="py-string">u'&#243;'</tt><tt class="py-op">:</tt> <tt class="py-string">u'o'</tt><tt class="py-op">,</tt> <tt class="py-string">u'&#250;'</tt><tt class="py-op">:</tt> <tt class="py-string">u'u'</tt><tt class="py-op">}</tt>  </tt>
<a name="L72"></a><tt class="py-lineno"> 72</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">k</tt><tt class="py-op">,</tt> <tt class="py-name">v</tt> <tt class="py-keyword">in</tt> <tt class="py-name">strs</tt><tt class="py-op">.</tt><tt class="py-name">items</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L73"></a><tt class="py-lineno"> 73</tt>  <tt class="py-line">                <tt class="py-name">texto</tt> <tt class="py-op">=</tt> <tt class="py-name">texto</tt><tt class="py-op">.</tt><tt class="py-name">replace</tt><tt class="py-op">(</tt><tt class="py-name">k</tt><tt class="py-op">,</tt> <tt class="py-name">v</tt><tt class="py-op">)</tt> </tt>
<a name="L74"></a><tt class="py-lineno"> 74</tt>  <tt class="py-line">                <tt class="py-name">texto</tt> <tt class="py-op">=</tt> <tt class="py-name">texto</tt><tt class="py-op">.</tt><tt class="py-name">replace</tt><tt class="py-op">(</tt><tt class="py-name">k</tt><tt class="py-op">.</tt><tt class="py-name">upper</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-name">v</tt><tt class="py-op">.</tt><tt class="py-name">upper</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L75"></a><tt class="py-lineno"> 75</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">texto</tt> </tt>
</div><a name="L76"></a><tt class="py-lineno"> 76</tt>  <tt class="py-line"> </tt>
<a name="L77"></a><tt class="py-lineno"> 77</tt>  <tt class="py-line"> </tt>
<a name="obtenerOracionesEtiquetadasFreeling"></a><div id="obtenerOracionesEtiquetadasFreeling-def"><a name="L78"></a><tt class="py-lineno"> 78</tt> <a class="py-toggle" href="#" id="obtenerOracionesEtiquetadasFreeling-toggle" onclick="return toggle('obtenerOracionesEtiquetadasFreeling');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pln_inco.Freeling-module.html#obtenerOracionesEtiquetadasFreeling">obtenerOracionesEtiquetadasFreeling</a><tt class="py-op">(</tt><tt class="py-param">text_file</tt><tt class="py-op">,</tt> <tt class="py-param">encoding</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="obtenerOracionesEtiquetadasFreeling-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="obtenerOracionesEtiquetadasFreeling-expanded"><a name="L79"></a><tt class="py-lineno"> 79</tt>  <tt class="py-line">        <tt class="py-docstring">"""Devuelve una lista de las oraciones identificadas por Freeling.</tt> </tt>
<a name="L80"></a><tt class="py-lineno"> 80</tt>  <tt class="py-line"><tt class="py-docstring">        </tt> </tt>
<a name="L81"></a><tt class="py-lineno"> 81</tt>  <tt class="py-line"><tt class="py-docstring">        Cada oraci&#243;n es una lista de tuplas (token, lema, tag gramatical).</tt> </tt>
<a name="L82"></a><tt class="py-lineno"> 82</tt>  <tt class="py-line"><tt class="py-docstring">        Para cada token de Freeling se devuelve una estructura TokenTexto con informaci&#243;n de la posici&#243;n</tt> </tt>
<a name="L83"></a><tt class="py-lineno"> 83</tt>  <tt class="py-line"><tt class="py-docstring">        de inicio y fin del token en el texto original.</tt> </tt>
<a name="L84"></a><tt class="py-lineno"> 84</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L85"></a><tt class="py-lineno"> 85</tt>  <tt class="py-line"><tt class="py-docstring">        El resultado es una lista cuyos elementos son [(TokenTexto, diccionario)] donde diccionario</tt> </tt>
<a name="L86"></a><tt class="py-lineno"> 86</tt>  <tt class="py-line"><tt class="py-docstring">        tiene la informaci&#243;n que brind&#243; Freeling (indexable por claves claves 'lema_freeling' y</tt> </tt>
<a name="L87"></a><tt class="py-lineno"> 87</tt>  <tt class="py-line"><tt class="py-docstring">        'tag_freeling').</tt> </tt>
<a name="L88"></a><tt class="py-lineno"> 88</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L89"></a><tt class="py-lineno"> 89</tt>  <tt class="py-line"><tt class="py-docstring">        En encoding se debe especificar la codificaci&#243;n del archivo de texto, por ejemplo 'iso-8859-1'</tt> </tt>
<a name="L90"></a><tt class="py-lineno"> 90</tt>  <tt class="py-line"><tt class="py-docstring">        o 'utf-8'."""</tt> </tt>
<a name="L91"></a><tt class="py-lineno"> 91</tt>  <tt class="py-line"> </tt>
<a name="L92"></a><tt class="py-lineno"> 92</tt>  <tt class="py-line">        <tt class="py-name">f</tt> <tt class="py-op">=</tt> <tt class="py-name">open</tt><tt class="py-op">(</tt><tt class="py-name">text_file</tt><tt class="py-op">,</tt> <tt class="py-string">'rU'</tt><tt class="py-op">)</tt> </tt>
<a name="L93"></a><tt class="py-lineno"> 93</tt>  <tt class="py-line">        <tt class="py-name">texto</tt> <tt class="py-op">=</tt> <tt class="py-name">f</tt><tt class="py-op">.</tt><tt class="py-name">read</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">decode</tt><tt class="py-op">(</tt><tt class="py-name">encoding</tt><tt class="py-op">)</tt> </tt>
<a name="L94"></a><tt class="py-lineno"> 94</tt>  <tt class="py-line">         </tt>
<a name="L95"></a><tt class="py-lineno"> 95</tt>  <tt class="py-line">        <tt class="py-name">tokens_mios</tt> <tt class="py-op">=</tt> <tt id="link-5" class="py-name" targets="Function pln_inco.util.Tokenizador.obtenerTokens()=pln_inco.util.Tokenizador-module.html#obtenerTokens"><a title="pln_inco.util.Tokenizador.obtenerTokens" class="py-name" href="#" onclick="return doclink('link-5', 'obtenerTokens', 'link-5');">obtenerTokens</a></tt><tt class="py-op">(</tt><tt class="py-name">texto</tt><tt class="py-op">)</tt> </tt>
<a name="L96"></a><tt class="py-lineno"> 96</tt>  <tt class="py-line">        <tt class="py-name">oraciones_freeling</tt> <tt class="py-op">=</tt> <tt id="link-6" class="py-name" targets="Function pln_inco.Freeling.obtenerInfoEtiquetadoFreeling()=pln_inco.Freeling-module.html#obtenerInfoEtiquetadoFreeling"><a title="pln_inco.Freeling.obtenerInfoEtiquetadoFreeling" class="py-name" href="#" onclick="return doclink('link-6', 'obtenerInfoEtiquetadoFreeling', 'link-6');">obtenerInfoEtiquetadoFreeling</a></tt><tt class="py-op">(</tt><tt class="py-name">texto</tt><tt class="py-op">)</tt> </tt>
<a name="L97"></a><tt class="py-lineno"> 97</tt>  <tt class="py-line"> </tt>
<a name="L98"></a><tt class="py-lineno"> 98</tt>  <tt class="py-line">        <tt class="py-name">f</tt><tt class="py-op">.</tt><tt class="py-name">close</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L99"></a><tt class="py-lineno"> 99</tt>  <tt class="py-line"> </tt>
<a name="L100"></a><tt class="py-lineno">100</tt>  <tt class="py-line">        <tt class="py-name">resultado</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L101"></a><tt class="py-lineno">101</tt>  <tt class="py-line">         </tt>
<a name="L102"></a><tt class="py-lineno">102</tt>  <tt class="py-line">        <tt class="py-name">j</tt> <tt class="py-op">=</tt> <tt class="py-number">0</tt> <tt class="py-comment"># &#205;ndice para recorrer tokens_mios</tt> </tt>
<a name="L103"></a><tt class="py-lineno">103</tt>  <tt class="py-line">         </tt>
<a name="L104"></a><tt class="py-lineno">104</tt>  <tt class="py-line">        <tt class="py-comment"># Recorremos todas las oraciones que nos dio Freeling</tt> </tt>
<a name="L105"></a><tt class="py-lineno">105</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">tokens_freeling</tt> <tt class="py-keyword">in</tt> <tt class="py-name">oraciones_freeling</tt><tt class="py-op">:</tt> </tt>
<a name="L106"></a><tt class="py-lineno">106</tt>  <tt class="py-line">         </tt>
<a name="L107"></a><tt class="py-lineno">107</tt>  <tt class="py-line">                <tt class="py-name">resultado_oracion</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L108"></a><tt class="py-lineno">108</tt>  <tt class="py-line"> </tt>
<a name="L109"></a><tt class="py-lineno">109</tt>  <tt class="py-line">                <tt class="py-comment"># Vamos recorriendo todos los tokens de Freeling de la oraci&#243;n.</tt> </tt>
<a name="L110"></a><tt class="py-lineno">110</tt>  <tt class="py-line">                <tt class="py-comment"># Asignamos el token de Freeling a una variable temporal token_freeling, y vamos</tt> </tt>
<a name="L111"></a><tt class="py-lineno">111</tt>  <tt class="py-line">                <tt class="py-comment"># "reconociendo" tokens nuestros dentro de &#233;ste.</tt> </tt>
<a name="L112"></a><tt class="py-lineno">112</tt>  <tt class="py-line">                <tt class="py-comment"># Si token_freeling queda vac&#237;o, entonces quiere decir que todos los tokens nuestros</tt> </tt>
<a name="L113"></a><tt class="py-lineno">113</tt>  <tt class="py-line">                <tt class="py-comment"># que est&#225;n dentro del token freeling fueron reconocidos y agregados a mis_tags.</tt> </tt>
<a name="L114"></a><tt class="py-lineno">114</tt>  <tt class="py-line">                <tt class="py-name">i</tt> <tt class="py-op">=</tt> <tt class="py-number">0</tt> </tt>
<a name="L115"></a><tt class="py-lineno">115</tt>  <tt class="py-line">                <tt class="py-keyword">while</tt> <tt class="py-name">i</tt> <tt class="py-op">&lt;</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">tokens_freeling</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L116"></a><tt class="py-lineno">116</tt>  <tt class="py-line">                        <tt class="py-op">(</tt><tt class="py-name">token_freeling</tt><tt class="py-op">,</tt> <tt class="py-name">lema</tt><tt class="py-op">,</tt> <tt class="py-name">tag_freeling</tt><tt class="py-op">)</tt> <tt class="py-op">=</tt> <tt class="py-name">tokens_freeling</tt><tt class="py-op">[</tt><tt class="py-name">i</tt><tt class="py-op">]</tt> </tt>
<a name="L117"></a><tt class="py-lineno">117</tt>  <tt class="py-line">                        <tt class="py-name">token_mio</tt> <tt class="py-op">=</tt> <tt class="py-name">tokens_mios</tt><tt class="py-op">[</tt><tt class="py-name">j</tt><tt class="py-op">]</tt> </tt>
<a name="L118"></a><tt class="py-lineno">118</tt>  <tt class="py-line"> </tt>
<a name="L119"></a><tt class="py-lineno">119</tt>  <tt class="py-line">                        <tt class="py-comment">#</tt> </tt>
<a name="L120"></a><tt class="py-lineno">120</tt>  <tt class="py-line">                        <tt class="py-comment"># Ej.</tt> </tt>
<a name="L121"></a><tt class="py-lineno">121</tt>  <tt class="py-line">                        <tt class="py-comment"># Token freeling = "A_pesar_de_todo"</tt> </tt>
<a name="L122"></a><tt class="py-lineno">122</tt>  <tt class="py-line">                        <tt class="py-comment"># Tokens mios = "A", "pesar", "de", "todo"</tt> </tt>
<a name="L123"></a><tt class="py-lineno">123</tt>  <tt class="py-line">                        <tt class="py-comment">#</tt> </tt>
<a name="L124"></a><tt class="py-lineno">124</tt>  <tt class="py-line">                        <tt class="py-comment"># Ej.</tt> </tt>
<a name="L125"></a><tt class="py-lineno">125</tt>  <tt class="py-line">                        <tt class="py-comment"># Tokens freeling = "de", "el"</tt> </tt>
<a name="L126"></a><tt class="py-lineno">126</tt>  <tt class="py-line">                        <tt class="py-comment"># Token mio = "del"</tt> </tt>
<a name="L127"></a><tt class="py-lineno">127</tt>  <tt class="py-line">                        <tt class="py-comment">#</tt> </tt>
<a name="L128"></a><tt class="py-lineno">128</tt>  <tt class="py-line">                        <tt class="py-comment"># Ej.</tt> </tt>
<a name="L129"></a><tt class="py-lineno">129</tt>  <tt class="py-line">                        <tt class="py-comment"># Tokens freeling = "con_el_culo_a_el_aire"</tt> </tt>
<a name="L130"></a><tt class="py-lineno">130</tt>  <tt class="py-line">                        <tt class="py-comment"># Tokens mios = "con", "el", "culo", "al", "aire".</tt> </tt>
<a name="L131"></a><tt class="py-lineno">131</tt>  <tt class="py-line">                        <tt class="py-comment"># (s&#237;, no se me ocurre otra por el momento :P)</tt> </tt>
<a name="L132"></a><tt class="py-lineno">132</tt>  <tt class="py-line">                        <tt class="py-comment">#</tt> </tt>
<a name="L133"></a><tt class="py-lineno">133</tt>  <tt class="py-line">                 </tt>
<a name="L134"></a><tt class="py-lineno">134</tt>  <tt class="py-line">                        <tt class="py-name">mi_TokenTexto_freeling</tt> <tt class="py-op">=</tt> <tt id="link-7" class="py-name" targets="Class pln_inco.util.Tokenizador.TokenTexto=pln_inco.util.Tokenizador.TokenTexto-class.html"><a title="pln_inco.util.Tokenizador.TokenTexto" class="py-name" href="#" onclick="return doclink('link-7', 'TokenTexto', 'link-7');">TokenTexto</a></tt><tt class="py-op">(</tt><tt class="py-name">token_freeling</tt><tt class="py-op">)</tt> </tt>
<a name="L135"></a><tt class="py-lineno">135</tt>  <tt class="py-line"> </tt>
<a name="L136"></a><tt class="py-lineno">136</tt>  <tt class="py-line">                        <tt class="py-keyword">while</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">token_freeling</tt><tt class="py-op">)</tt> <tt class="py-op">&gt;</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L137"></a><tt class="py-lineno">137</tt>  <tt class="py-line">                 </tt>
<a name="L138"></a><tt class="py-lineno">138</tt>  <tt class="py-line">                                <tt class="py-comment">#print '-&gt; %s %s' % (token_mio.texto, token_freeling)</tt> </tt>
<a name="L139"></a><tt class="py-lineno">139</tt>  <tt class="py-line">                         </tt>
<a name="L140"></a><tt class="py-lineno">140</tt>  <tt class="py-line">                                <tt class="py-comment"># Casos especiales</tt> </tt>
<a name="L141"></a><tt class="py-lineno">141</tt>  <tt class="py-line">                                <tt class="py-comment">#        del -&gt; de el</tt> </tt>
<a name="L142"></a><tt class="py-lineno">142</tt>  <tt class="py-line">                                <tt class="py-comment">#        al -&gt; a el</tt> </tt>
<a name="L143"></a><tt class="py-lineno">143</tt>  <tt class="py-line">                                <tt class="py-comment">#</tt> </tt>
<a name="L144"></a><tt class="py-lineno">144</tt>  <tt class="py-line">                                <tt class="py-comment"># Cuidado especial en casos de locuciones como "con_el_culo_a_el_aire", donde el token_freeling</tt> </tt>
<a name="L145"></a><tt class="py-lineno">145</tt>  <tt class="py-line">                                <tt class="py-comment"># eventualmente ser&#225; algo como "a_el_aire".</tt> </tt>
<a name="L146"></a><tt class="py-lineno">146</tt>  <tt class="py-line">                                <tt class="py-comment">#</tt> </tt>
<a name="L147"></a><tt class="py-lineno">147</tt>  <tt class="py-line">                                <tt class="py-name">caso_del</tt> <tt class="py-op">=</tt> <tt class="py-name">token_mio</tt><tt class="py-op">.</tt><tt class="py-name">texto</tt><tt class="py-op">.</tt><tt class="py-name">lower</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-string">'del'</tt> <tt class="py-keyword">and</tt> <tt class="py-name">token_freeling</tt><tt class="py-op">.</tt><tt class="py-name">lower</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-number">3</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-string">'del'</tt> <tt class="py-keyword">and</tt> <tt class="py-name">token_freeling</tt><tt class="py-op">.</tt><tt class="py-name">lower</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-number">2</tt><tt class="py-op">]</tt> <tt class="py-op">==</tt> <tt class="py-string">'de'</tt> </tt>
<a name="L148"></a><tt class="py-lineno">148</tt>  <tt class="py-line">                                <tt class="py-name">caso_al</tt> <tt class="py-op">=</tt> <tt class="py-name">token_mio</tt><tt class="py-op">.</tt><tt class="py-name">texto</tt><tt class="py-op">.</tt><tt class="py-name">lower</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-string">'al'</tt> <tt class="py-keyword">and</tt> <tt class="py-name">token_freeling</tt><tt class="py-op">.</tt><tt class="py-name">lower</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-number">2</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-string">'al'</tt> <tt class="py-keyword">and</tt> <tt class="py-name">token_freeling</tt><tt class="py-op">.</tt><tt class="py-name">lower</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">==</tt> <tt class="py-string">'a'</tt> </tt>
<a name="L149"></a><tt class="py-lineno">149</tt>  <tt class="py-line">                         </tt>
<a name="L150"></a><tt class="py-lineno">150</tt>  <tt class="py-line">                                <tt class="py-comment"># Casos de sufijos</tt> </tt>
<a name="L151"></a><tt class="py-lineno">151</tt>  <tt class="py-line">                                <tt class="py-comment">#       cont&#225;ndoselo -&gt; contando se lo</tt> </tt>
<a name="L152"></a><tt class="py-lineno">152</tt>  <tt class="py-line">                                <tt class="py-comment">#       v&#225;monos -&gt; vamos nos</tt> </tt>
<a name="L153"></a><tt class="py-lineno">153</tt>  <tt class="py-line">                                <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">token_freeling</tt><tt class="py-op">)</tt> <tt class="py-op">&lt;</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">token_mio</tt><tt class="py-op">.</tt><tt class="py-name">texto</tt><tt class="py-op">)</tt> <tt class="py-keyword">and</tt> <tt class="py-keyword">not</tt> <tt class="py-op">(</tt><tt class="py-name">caso_del</tt> <tt class="py-keyword">or</tt> <tt class="py-name">caso_al</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L154"></a><tt class="py-lineno">154</tt>  <tt class="py-line">                                        <tt class="py-comment">#print '-&gt; %s %s' % (token_mio.texto, token_freeling)</tt> </tt>
<a name="L155"></a><tt class="py-lineno">155</tt>  <tt class="py-line">                         </tt>
<a name="L156"></a><tt class="py-lineno">156</tt>  <tt class="py-line">                                        <tt class="py-comment"># Ej.</tt> </tt>
<a name="L157"></a><tt class="py-lineno">157</tt>  <tt class="py-line">                                        <tt class="py-comment"># token_freeling: contando</tt> </tt>
<a name="L158"></a><tt class="py-lineno">158</tt>  <tt class="py-line">                                        <tt class="py-comment"># token_mio: cont&#225;ndoselo</tt> </tt>
<a name="L159"></a><tt class="py-lineno">159</tt>  <tt class="py-line">                                        <tt class="py-name">mio_sin_tildes</tt> <tt class="py-op">=</tt> <tt id="link-8" class="py-name" targets="Function pln_inco.Freeling.sacarTildes()=pln_inco.Freeling-module.html#sacarTildes"><a title="pln_inco.Freeling.sacarTildes" class="py-name" href="#" onclick="return doclink('link-8', 'sacarTildes', 'link-8');">sacarTildes</a></tt><tt class="py-op">(</tt><tt class="py-name">token_mio</tt><tt class="py-op">.</tt><tt class="py-name">texto</tt><tt class="py-op">)</tt> </tt>
<a name="L160"></a><tt class="py-lineno">160</tt>  <tt class="py-line">                                 </tt>
<a name="L161"></a><tt class="py-lineno">161</tt>  <tt class="py-line">                                        <tt class="py-comment"># Ej.</tt> </tt>
<a name="L162"></a><tt class="py-lineno">162</tt>  <tt class="py-line">                                        <tt class="py-comment"># token_freeling: contando</tt> </tt>
<a name="L163"></a><tt class="py-lineno">163</tt>  <tt class="py-line">                                        <tt class="py-comment"># mio_sin_tildes: contandoselo</tt> </tt>
<a name="L164"></a><tt class="py-lineno">164</tt>  <tt class="py-line">                                 </tt>
<a name="L165"></a><tt class="py-lineno">165</tt>  <tt class="py-line">                                        <tt class="py-name">mi_TokenTexto_freeling</tt><tt class="py-op">.</tt><tt class="py-name">ini</tt> <tt class="py-op">=</tt> <tt class="py-name">token_mio</tt><tt class="py-op">.</tt><tt class="py-name">ini</tt> </tt>
<a name="L166"></a><tt class="py-lineno">166</tt>  <tt class="py-line">                                        <tt class="py-name">mi_TokenTexto_freeling</tt><tt class="py-op">.</tt><tt class="py-name">fin</tt> <tt class="py-op">=</tt> <tt class="py-name">token_mio</tt><tt class="py-op">.</tt><tt class="py-name">fin</tt> </tt>
<a name="L167"></a><tt class="py-lineno">167</tt>  <tt class="py-line">                                        <tt class="py-name">resultado_oracion</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-op">(</tt><tt class="py-name">mi_TokenTexto_freeling</tt><tt class="py-op">,</tt> <tt class="py-op">{</tt><tt class="py-string">'lema_freeling'</tt> <tt class="py-op">:</tt> <tt class="py-name">lema</tt><tt class="py-op">,</tt> <tt class="py-string">'tag_freeling'</tt> <tt class="py-op">:</tt> <tt class="py-name">tag_freeling</tt><tt class="py-op">}</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L168"></a><tt class="py-lineno">168</tt>  <tt class="py-line">                                 </tt>
<a name="L169"></a><tt class="py-lineno">169</tt>  <tt class="py-line">                                        <tt class="py-name">resto</tt> <tt class="py-op">=</tt> <tt class="py-name">mio_sin_tildes</tt><tt class="py-op">.</tt><tt class="py-name">replace</tt><tt class="py-op">(</tt><tt class="py-name">token_freeling</tt><tt class="py-op">,</tt> <tt class="py-string">''</tt><tt class="py-op">,</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt> </tt>
<a name="L170"></a><tt class="py-lineno">170</tt>  <tt class="py-line">                                        <tt class="py-keyword">if</tt> <tt class="py-name">resto</tt> <tt class="py-op">==</tt> <tt class="py-name">mio_sin_tildes</tt><tt class="py-op">:</tt> </tt>
<a name="L171"></a><tt class="py-lineno">171</tt>  <tt class="py-line">                                                <tt class="py-comment"># Por un caso particular "v&#225;monos" que Freeling separa en "vamos", "nos".</tt> </tt>
<a name="L172"></a><tt class="py-lineno">172</tt>  <tt class="py-line">                                                <tt class="py-comment"># Falla al reemplazar.</tt> </tt>
<a name="L173"></a><tt class="py-lineno">173</tt>  <tt class="py-line">                                                <tt class="py-comment">#</tt> </tt>
<a name="L174"></a><tt class="py-lineno">174</tt>  <tt class="py-line">                                                <tt class="py-comment"># Consideramos el caso cuando la palabra original termina en s</tt> </tt>
<a name="L175"></a><tt class="py-lineno">175</tt>  <tt class="py-line">                                                <tt class="py-keyword">if</tt> <tt class="py-name">token_freeling</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt class="py-name">lower</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-string">'s'</tt><tt class="py-op">:</tt> </tt>
<a name="L176"></a><tt class="py-lineno">176</tt>  <tt class="py-line">                                                        <tt class="py-name">token_freeling</tt> <tt class="py-op">=</tt> <tt class="py-name">token_freeling</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
<a name="L177"></a><tt class="py-lineno">177</tt>  <tt class="py-line">                                                <tt class="py-name">resto</tt> <tt class="py-op">=</tt> <tt class="py-name">mio_sin_tildes</tt><tt class="py-op">.</tt><tt class="py-name">replace</tt><tt class="py-op">(</tt><tt class="py-name">token_freeling</tt><tt class="py-op">,</tt> <tt class="py-string">''</tt><tt class="py-op">,</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt> </tt>
<a name="L178"></a><tt class="py-lineno">178</tt>  <tt class="py-line">                                         </tt>
<a name="L179"></a><tt class="py-lineno">179</tt>  <tt class="py-line">                                                <tt class="py-keyword">if</tt> <tt class="py-name">resto</tt> <tt class="py-op">==</tt> <tt class="py-name">mio_sin_tildes</tt><tt class="py-op">:</tt> </tt>
<a name="L180"></a><tt class="py-lineno">180</tt>  <tt class="py-line">                                                        <tt class="py-keyword">print</tt> <tt class="py-string">u'Problema reemplazando "%s" en "%s", quiz&#225; explote al devolver los tokens de Freeling.'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">token_freeling</tt><tt class="py-op">,</tt> <tt class="py-name">mio_sin_tildes</tt><tt class="py-op">)</tt> </tt>
<a name="L181"></a><tt class="py-lineno">181</tt>  <tt class="py-line"> </tt>
<a name="L182"></a><tt class="py-lineno">182</tt>  <tt class="py-line">                                        <tt class="py-comment"># Ej.</tt> </tt>
<a name="L183"></a><tt class="py-lineno">183</tt>  <tt class="py-line">                                        <tt class="py-comment"># resto: selo</tt> </tt>
<a name="L184"></a><tt class="py-lineno">184</tt>  <tt class="py-line">                                        <tt class="py-comment">#print 'Inserto resto=%s' % resto</tt> </tt>
<a name="L185"></a><tt class="py-lineno">185</tt>  <tt class="py-line">                                        <tt class="py-name">tokens_mios</tt><tt class="py-op">.</tt><tt class="py-name">insert</tt><tt class="py-op">(</tt><tt class="py-name">j</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">,</tt> <tt id="link-9" class="py-name"><a title="pln_inco.util.Tokenizador.TokenTexto" class="py-name" href="#" onclick="return doclink('link-9', 'TokenTexto', 'link-7');">TokenTexto</a></tt><tt class="py-op">(</tt><tt class="py-name">resto</tt><tt class="py-op">,</tt> <tt class="py-name">token_mio</tt><tt class="py-op">.</tt><tt class="py-name">ini</tt><tt class="py-op">,</tt> <tt class="py-name">token_mio</tt><tt class="py-op">.</tt><tt class="py-name">fin</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L186"></a><tt class="py-lineno">186</tt>  <tt class="py-line">                                 </tt>
<a name="L187"></a><tt class="py-lineno">187</tt>  <tt class="py-line">                                        <tt class="py-name">token_freeling</tt> <tt class="py-op">=</tt> <tt class="py-string">''</tt> </tt>
<a name="L188"></a><tt class="py-lineno">188</tt>  <tt class="py-line">                                        <tt class="py-name">j</tt> <tt class="py-op">+=</tt> <tt class="py-number">1</tt> </tt>
<a name="L189"></a><tt class="py-lineno">189</tt>  <tt class="py-line">                                 </tt>
<a name="L190"></a><tt class="py-lineno">190</tt>  <tt class="py-line">                                <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L191"></a><tt class="py-lineno">191</tt>  <tt class="py-line"> </tt>
<a name="L192"></a><tt class="py-lineno">192</tt>  <tt class="py-line">                                        <tt class="py-keyword">if</tt> <tt class="py-name">caso_del</tt> <tt class="py-keyword">or</tt> <tt class="py-name">caso_al</tt><tt class="py-op">:</tt> </tt>
<a name="L193"></a><tt class="py-lineno">193</tt>  <tt class="py-line">                                 </tt>
<a name="L194"></a><tt class="py-lineno">194</tt>  <tt class="py-line">                                                <tt class="py-comment"># Cambiamos nuestros token "del" o "al" por "de" y "a", y agregamos el "el" que falta</tt> </tt>
<a name="L195"></a><tt class="py-lineno">195</tt>  <tt class="py-line">                                                <tt class="py-keyword">if</tt> <tt class="py-name">caso_del</tt><tt class="py-op">:</tt> </tt>
<a name="L196"></a><tt class="py-lineno">196</tt>  <tt class="py-line">                                                        <tt class="py-name">token_mio</tt><tt class="py-op">.</tt><tt class="py-name">texto</tt> <tt class="py-op">=</tt> <tt class="py-string">'de'</tt> </tt>
<a name="L197"></a><tt class="py-lineno">197</tt>  <tt class="py-line">                                                <tt class="py-keyword">elif</tt> <tt class="py-name">caso_al</tt><tt class="py-op">:</tt> </tt>
<a name="L198"></a><tt class="py-lineno">198</tt>  <tt class="py-line">                                                        <tt class="py-name">token_mio</tt><tt class="py-op">.</tt><tt class="py-name">texto</tt> <tt class="py-op">=</tt> <tt class="py-string">'a'</tt> </tt>
<a name="L199"></a><tt class="py-lineno">199</tt>  <tt class="py-line">                                 </tt>
<a name="L200"></a><tt class="py-lineno">200</tt>  <tt class="py-line">                                                <tt class="py-name">tokens_mios</tt><tt class="py-op">.</tt><tt class="py-name">insert</tt><tt class="py-op">(</tt><tt class="py-name">j</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">,</tt> <tt id="link-10" class="py-name"><a title="pln_inco.util.Tokenizador.TokenTexto" class="py-name" href="#" onclick="return doclink('link-10', 'TokenTexto', 'link-7');">TokenTexto</a></tt><tt class="py-op">(</tt><tt class="py-string">'el'</tt><tt class="py-op">,</tt> <tt class="py-name">token_mio</tt><tt class="py-op">.</tt><tt class="py-name">ini</tt><tt class="py-op">,</tt> <tt class="py-name">token_mio</tt><tt class="py-op">.</tt><tt class="py-name">fin</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L201"></a><tt class="py-lineno">201</tt>  <tt class="py-line"> </tt>
<a name="L202"></a><tt class="py-lineno">202</tt>  <tt class="py-line">                                        <tt class="py-comment"># token_mio deber&#237;a estar al principio en token_freeling</tt> </tt>
<a name="L203"></a><tt class="py-lineno">203</tt>  <tt class="py-line">                                        <tt class="py-comment"># Lo borramos del token_freeling</tt> </tt>
<a name="L204"></a><tt class="py-lineno">204</tt>  <tt class="py-line">                         </tt>
<a name="L205"></a><tt class="py-lineno">205</tt>  <tt class="py-line">                                        <tt class="py-name">token_freeling_viejo</tt> <tt class="py-op">=</tt> <tt class="py-name">token_freeling</tt> </tt>
<a name="L206"></a><tt class="py-lineno">206</tt>  <tt class="py-line">                                        <tt class="py-name">token_freeling</tt> <tt class="py-op">=</tt> <tt class="py-name">token_freeling</tt><tt class="py-op">.</tt><tt class="py-name">replace</tt><tt class="py-op">(</tt><tt class="py-name">token_mio</tt><tt class="py-op">.</tt><tt class="py-name">texto</tt><tt class="py-op">,</tt> <tt class="py-string">''</tt><tt class="py-op">,</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt> </tt>
<a name="L207"></a><tt class="py-lineno">207</tt>  <tt class="py-line">                                        <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">token_freeling</tt><tt class="py-op">)</tt> <tt class="py-op">&gt;</tt> <tt class="py-number">0</tt> <tt class="py-keyword">and</tt> <tt class="py-name">token_freeling</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> <tt class="py-op">==</tt> <tt class="py-string">'_'</tt><tt class="py-op">:</tt> </tt>
<a name="L208"></a><tt class="py-lineno">208</tt>  <tt class="py-line">                                                <tt class="py-name">token_freeling</tt> <tt class="py-op">=</tt> <tt class="py-name">token_freeling</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> </tt>
<a name="L209"></a><tt class="py-lineno">209</tt>  <tt class="py-line">                         </tt>
<a name="L210"></a><tt class="py-lineno">210</tt>  <tt class="py-line">                                        <tt class="py-comment"># Si no hizo nada, caso raro. Probablemente sea porque quedan caracteres raros al final del token de Freeling.</tt> </tt>
<a name="L211"></a><tt class="py-lineno">211</tt>  <tt class="py-line">                                        <tt class="py-keyword">if</tt> <tt class="py-name">token_freeling_viejo</tt> <tt class="py-op">==</tt> <tt class="py-name">token_freeling</tt><tt class="py-op">:</tt> </tt>
<a name="L212"></a><tt class="py-lineno">212</tt>  <tt class="py-line">                                                <tt class="py-name">token_freeling</tt> <tt class="py-op">=</tt> <tt class="py-string">''</tt> </tt>
<a name="L213"></a><tt class="py-lineno">213</tt>  <tt class="py-line"> </tt>
<a name="L214"></a><tt class="py-lineno">214</tt>  <tt class="py-line">                                        <tt class="py-comment"># Seteamos el ini (si ya lo hab&#237;amos seteado, el valor ser&#225; distinto a -1)</tt> </tt>
<a name="L215"></a><tt class="py-lineno">215</tt>  <tt class="py-line">                                        <tt class="py-keyword">if</tt> <tt class="py-name">mi_TokenTexto_freeling</tt><tt class="py-op">.</tt><tt class="py-name">ini</tt> <tt class="py-op">==</tt> <tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
<a name="L216"></a><tt class="py-lineno">216</tt>  <tt class="py-line">                                                <tt class="py-name">mi_TokenTexto_freeling</tt><tt class="py-op">.</tt><tt class="py-name">ini</tt> <tt class="py-op">=</tt> <tt class="py-name">token_mio</tt><tt class="py-op">.</tt><tt class="py-name">ini</tt> </tt>
<a name="L217"></a><tt class="py-lineno">217</tt>  <tt class="py-line">                                        <tt class="py-comment"># Seteamos el fin (si token_freeling qued&#243; vac&#237;o, y por lo tanto terminamos de reconocer)</tt> </tt>
<a name="L218"></a><tt class="py-lineno">218</tt>  <tt class="py-line">                                        <tt class="py-comment"># y agregamos a la lista...</tt> </tt>
<a name="L219"></a><tt class="py-lineno">219</tt>  <tt class="py-line">                                        <tt class="py-keyword">if</tt> <tt class="py-name">token_freeling</tt> <tt class="py-op">==</tt> <tt class="py-string">''</tt><tt class="py-op">:</tt> </tt>
<a name="L220"></a><tt class="py-lineno">220</tt>  <tt class="py-line">                                                <tt class="py-name">mi_TokenTexto_freeling</tt><tt class="py-op">.</tt><tt class="py-name">fin</tt> <tt class="py-op">=</tt> <tt class="py-name">token_mio</tt><tt class="py-op">.</tt><tt class="py-name">fin</tt> </tt>
<a name="L221"></a><tt class="py-lineno">221</tt>  <tt class="py-line">                                                <tt class="py-name">resultado_oracion</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-op">(</tt><tt class="py-name">mi_TokenTexto_freeling</tt><tt class="py-op">,</tt> <tt class="py-op">{</tt><tt class="py-string">'lema_freeling'</tt> <tt class="py-op">:</tt> <tt class="py-name">lema</tt><tt class="py-op">,</tt> <tt class="py-string">'tag_freeling'</tt> <tt class="py-op">:</tt> <tt class="py-name">tag_freeling</tt><tt class="py-op">}</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L222"></a><tt class="py-lineno">222</tt>  <tt class="py-line"> </tt>
<a name="L223"></a><tt class="py-lineno">223</tt>  <tt class="py-line">                                        <tt class="py-name">j</tt> <tt class="py-op">+=</tt> <tt class="py-number">1</tt> </tt>
<a name="L224"></a><tt class="py-lineno">224</tt>  <tt class="py-line">                                        <tt class="py-comment"># Agarramos el siguiente si los hay</tt> </tt>
<a name="L225"></a><tt class="py-lineno">225</tt>  <tt class="py-line">                                        <tt class="py-keyword">if</tt> <tt class="py-name">j</tt> <tt class="py-op">&lt;</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">tokens_mios</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L226"></a><tt class="py-lineno">226</tt>  <tt class="py-line">                                                <tt class="py-name">token_mio</tt> <tt class="py-op">=</tt> <tt class="py-name">tokens_mios</tt><tt class="py-op">[</tt><tt class="py-name">j</tt><tt class="py-op">]</tt> </tt>
<a name="L227"></a><tt class="py-lineno">227</tt>  <tt class="py-line"> </tt>
<a name="L228"></a><tt class="py-lineno">228</tt>  <tt class="py-line">                        <tt class="py-name">i</tt> <tt class="py-op">+=</tt> <tt class="py-number">1</tt> </tt>
<a name="L229"></a><tt class="py-lineno">229</tt>  <tt class="py-line">                 </tt>
<a name="L230"></a><tt class="py-lineno">230</tt>  <tt class="py-line">                <tt class="py-name">resultado</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-name">resultado_oracion</tt><tt class="py-op">)</tt> </tt>
<a name="L231"></a><tt class="py-lineno">231</tt>  <tt class="py-line"> </tt>
<a name="L232"></a><tt class="py-lineno">232</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">resultado</tt> </tt>
</div><a name="L233"></a><tt class="py-lineno">233</tt>  <tt class="py-line"> </tt>
<a name="L234"></a><tt class="py-lineno">234</tt>  <tt class="py-line"> </tt>
<a name="L235"></a><tt class="py-lineno">235</tt>  <tt class="py-line"><tt class="py-name">__all__</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-string">'obtenerOracionesEtiquetadasFreeling'</tt><tt class="py-op">,</tt> <tt class="py-string">'obtenerSalidaFreeling'</tt><tt class="py-op">,</tt> <tt class="py-string">'obtenerInfoEtiquetadoFreeling'</tt><tt class="py-op">]</tt> </tt>
<a name="L236"></a><tt class="py-lineno">236</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            >alan</th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Thu Oct 21 00:21:15 2010
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
